package com.example.lib_cache.database;

import androidx.annotation.NonNull;
import androidx.room.Database;
import androidx.room.DatabaseConfiguration;
import androidx.room.InvalidationTracker;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.sqlite.db.SupportSQLiteOpenHelper;

import com.example.lib_cache.dao.UserDao;
import com.example.lib_cache.model.User;
import com.example.lib_common.util.AppGlobals;

@Database(entities = {User.class}, version = 1)
public abstract class CacheDataBase extends RoomDatabase {

    private static final CacheDataBase dataBase;

    static {
        //创建数据库
        dataBase = Room.databaseBuilder(AppGlobals.getApplication(), CacheDataBase.class, "db")
                .allowMainThreadQueries() //声明可以在主线程中查询
                .build()
        ;
    }

    public static CacheDataBase getDataBase() {
        return dataBase;
    }

    public abstract UserDao userDao();


}
